package com.woniuxy.project.entity;

import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class UserDetails {
    private Integer uid;
    private String uname;
    private String phone;
    private String gender;
    private String idcard;
    private String bankcard;
    private String openstate;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime time;
    private String firmname;
    private String legalperson;
    private BigDecimal investmoney;
    private BigDecimal uncompletedmoney;
    private Integer type;

    public void setIdcard(String idcard) {
        this.idcard = idcard.substring(0, 6) + "********" + idcard.substring(14);
    }

    public void setBankcard(String bankcard) {
        int length = bankcard.length();
        String startSegment = bankcard.substring(0, 6); // 前6位
        String endSegment = bankcard.substring(length - 4); // 后4位
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length - 10; i++) {
            sb.append('*');
        }
        this.bankcard = startSegment + sb + endSegment;
    }
}
